﻿using System.Data;
using System.Data.SqlClient;

namespace HHL_Acc.HHL_DaoAcc.DataObject
{
    public class DataBaseDao : CBaseDao
    {
        public DataTable GetDataBaseList()
        {
            string sql = "[app].[usp_TOL_LNG_GetAllDatabases]";
            DataSet ds = ExcuteSql(sql, CommandType.StoredProcedure);
            if (ds != null && ds.Tables.Count > 0)
                return ds.Tables[0];
            return null;
        }

        public DataTable GetTableList(string dataBaseName)
        {
            string sql = "[app].[usp_TOL_LNG_GetAllDatabases]";
            DataSet ds = ExcuteSql(sql, CommandType.StoredProcedure, new SqlParameter("@DatabaseName", dataBaseName));
            if (ds != null && ds.Tables.Count > 0)
                return ds.Tables[0];
            return null;
        }


        public DataTable GetColumnsList(string dataBaseName, string tableName)
        {
            string sql = "app.usp_TOL_LNG_GetColumnsOfTable";
            DataSet ds = ExcuteSql(sql, CommandType.StoredProcedure, new SqlParameter("@DatabaseName", dataBaseName),
                                   new SqlParameter("@TableName", tableName));
            if (ds != null && ds.Tables.Count > 0)
                return ds.Tables[0];
            return null;
        }
    }
}